import 'package:flutter/material.dart';

class ColorHelper{

  ColorHelper._();

  ///==============================主要颜色==============================
  ///蓝色 主题颜色 3478F5
  static Color mainBlueColor = hexToColor("#3478F5");
  //蓝色按钮按下颜色 (浅蓝色)
  static Color mainWathetColor = hexToColor("#99BBFA");
  //登录按钮按下
  static Color mainPressBlueColor = hexToColor("#2E6EE2");
  //取消按钮的浅蓝色边框
  static Color mainWathet2Color = hexToColor("#99BBFA");
  static Color mainCBAB74 = hexToColor("#CBAB74");

  ///==============================主要颜色==============================

  ///==============================辅助颜色==============================
  ///auxiliary - 辅助  简称 a
  //深蓝色（蓝色中带点黑）
  static Color aDarkBlueColor = hexToColor("#5B6A91");
  //浅灰蓝色
  static Color aLightGreyBlueColor = hexToColor("#ADB4C8");
//  浅蓝色
//  static Color aLightGreyBlueColor = hexToColor("#ADB4C8");
  //红色 警告色
  static Color aRedColor = hexToColor("#EE1010");
  //红色按下时的颜色
  static Color aLightRedColor = hexToColor("#F78888");
  static Color aKhakiColor = hexToColor("#FFEDBD");
  //==============================辅助颜色==============================

  //==============================灰度颜色==============================
  ///黑色 字体的默认
  ///Grayscale  191919
  static Color gBlackColor = hexToColor("#191919");
  ///灰色1 （提示文字）7F7F7F
  static Color gPromptTextColor = hexToColor("#7F7F7F");
  //灰色2 （分割线）
  static Color gDividingLineColor = hexToColor("#F4F4F4F4");
  //灰色1 （遮罩）
  static Color gMaskColor = hexToColor("#12000000");
  ///背景色
  static Color gBackgroundColor = hexToColor("#F6F6F6");
  //分割线
  static Color gShallowDividingLineColor = hexToColor("#DCDCDC");
  //协议字体颜色
  static Color gAgreementTipsColor = hexToColor("#999999");
//  设置头像
  static Color gSettingUpaHeadColor = hexToColor("#CDCDCD");
  //简介提示
  static Color gBriefIntroductionColor = hexToColor("#BDBDBD");
  static Color geef4ff = hexToColor("#EEF4FF");
  static Color g639aff = hexToColor("#639AFF");
  static Color gC9C9C9 = hexToColor("#C9C9C9");
  static Color g8B8B8B = hexToColor("#8B8B8B");
  static Color gB2B2B2 = hexToColor("#B2B2B2");
  static Color g373737 = hexToColor("#373737");
  static Color gDEDEDE = hexToColor("#DEDEDE");
  static Color g4D4D4D = hexToColor("#DEDEDE");
  ///==============================灰度颜色==============================
  /// 小组详情页背景色
  static const Color bgColor = Color.fromRGBO(52, 75, 98, 1);
  /// 添加任务背景色
  static const Color addBackgroudColor = Color.fromRGBO(22, 41, 61, 1);
  /// 背景色
  static const Color whiteBackgroudColor245 = Color.fromRGBO(245, 245, 245, 1);
  /// 背景色
  static const Color whiteBackgroudColor249 = Color.fromRGBO(249, 249, 249, 1);
  /// 未读消息背景色
  static const Color unreadMessageBGColor = Color.fromRGBO(50, 50, 50, 1);
  /// 字体颜色
  static const Color fontGreyColor = Color.fromRGBO(125, 125, 125, 1);
  /// 按钮禁用颜色
  static Color disableColor = hexColor('#3478F5',alpha: 0.5);

  /// 十六进制字符串颜色,
  /// str, 十六进制值，例如：#FA6400,
  /// alpha, 透明度 [0.0,1.0]
  static Color hexColor(String str,{double alpha = 1}){

    if (str.contains('#')) {
      str = str.replaceFirst('#', '0x');
    }else if(str.length == 6){
      str = '0x' + str;
    }
    int hex = int.parse(str);
    if (alpha < 0){
      alpha = 0;
    }else if (alpha > 1){
      alpha = 1;
    }
    return Color.fromRGBO((hex & 0xFF0000) >> 16 ,
        (hex & 0x00FF00) >> 8,
        (hex & 0x0000FF) >> 0,
        alpha);
  }
  static Color hexToColor(String s) {
// 如果传入的十六进制颜色值不符合要求，返回默认值
    if (s == null ||
        s.length != 7 ||
        int.tryParse(s.substring(1, 7), radix: 16) == null) {
      s = '#999999';
    }
    return new Color(int.parse(s.substring(1, 7), radix: 16) + 0xFF000000);
  }
}